﻿namespace NiuX.AspNetCore;

public class AppScope
{
    public static async Task Execute(Func<Task> func)
    {
        await using var scope = App.ServiceProvider.CreateAsyncScope();
        await func();
    }

    public static async Task Execute(Func<IServiceProvider, Task> func)
    {
        await using var scope = App.ServiceProvider.CreateAsyncScope();
        await func(scope.ServiceProvider);
    }

}